<?php
/**
 * TbSyncLog.php class file.
 * @author shengxia <523247758@qq.com>
 * @date 2021/01/06- 5:13 下午
 */

namespace common\models;

use common\models\pdd\PddBatchSyncLogProducts as BasePddSyncLog;
use common\components\api\isv\Goods;

class PddBatchSyncLogProducts extends BasePddSyncLog
{
    /**
     * 获取修改记录列表
     * @param int $page
     * @param int $pageSize
     * @param array $args
     * @return array
     */
    public function getListPage(int $page = 1, int $pageSize = 10, array $args = [])
    {


        $query = PddBatchSyncLogProducts::find();
        $query->select(['batchType', 'type', 'status', 'batch_no', 'goods_id', 'error_info', 'aftercontent', 'beftercontent', 'created_at', 'updated_at']);
        $keywordsTitle = [];
        if (count($args)) {
            $offset = ($page - 1) * $pageSize;
            /**
             * 默认按照id 倒叙排序
             */
            $query->orderBy('created_at DESC');
            if (isset($args['goods_id'])) {
                $query->where(['goods_id' => $args['goods_id']]);
            }
            if (isset($args['batch_no'])) {
                $query->where(['batch_no' => $args['batch_no']]);
            }
            $count = $query->count();
            $query->limit($pageSize)->offset($offset);
            $list = $query->asArray()->all();
        }

        return [$count, $list];

    }
}
